//
// Created by xili on 2024/7/31 14:11.
// Go big or go home.
//

using namespace std;

class Solution {
public:
    int kItemsWithMaximumSum(int numOnes, int numZeros, int numNegOnes, int k) {
        if (k <= numOnes) {
            return k;
        } else if (k <= numOnes + numZeros) {
            return numOnes;
        }
        return numOnes - (numOnes - k);
    }
};
